// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import FastClick from 'fastclick'
import router from './router'
import App from './App'
import  {ToastPlugin, LoadingPlugin} from 'vux'

Vue.use(ToastPlugin)
Vue.use(LoadingPlugin)
FastClick.attach(document.body)

if(process.env.NODE_ENV === 'production'){
  //生产环境 关闭警告 vue-devtools
  Vue.config.productionTip = false
  Vue.config.devtools = false
}

let getSystemVersion = function () {
  let userAgents = navigator.userAgent;
  let indexs = userAgents.indexOf("Android")
  let screenObj = {}
  console.log(userAgents)
  console.log(indexs)
  if(indexs >= 0){
    let androidVersion = parseFloat(userAgents.slice(indexs+8))
    screenObj.androidVersion = androidVersion
  } else {
    screenObj.otherMobile = indexs
  }
  screenObj.screenWidths = window.screen.width
  screenObj.screenHeights = window.screen.height
  screenObj.dprs = window.devicePixelRatio
  window.sessionStorage.screenObj = JSON.stringify(screenObj)
  console.log(screenObj)
}
getSystemVersion()

//弹窗toast
Vue.prototype.$toast = function (str, type) {
  this.$vux.toast.show({
    time: "1000",
    text: str,
    type: type || 'text',
    width: str.length + 1 + 'em'
  })
}

/* eslint-disable no-new */
new Vue({
  router,
  render: h => h(App)
}).$mount('#app-box')
